#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <openssl/aes.h>
#include "gaia_aes_cbc.h"


//#define MSG_LEN 256

int main (int argc, char * argv[]) 
{
  if(argc < 2)
  {
    fprintf(stderr,"Please input encrypt string!\n");
    return 1;
  }
  // 加密密钥 
  char key[AES_BLOCK_SIZE];
  char SourceData[MSG_LEN];
  char DstData[MSG_LEN];
  int i = 0;

  //memset(key,"*&Eks_@+=!$%^739",AES_BLOCK_SIZE);
  memset(key,'\0',AES_BLOCK_SIZE);
  //memset( (char *)SourceData,0,MSG_LEN);
  memset( (char *)DstData,'\0',MSG_LEN);

  //SourceData = argv[1];
  strcpy((char *)SourceData,argv[1]);
  strcpy(key,"*&Eks_@+=!$%^739");

  if(gaia_aes_encrypt(SourceData,key,DstData))
  {
    fprintf(stderr,"encrypt error!\n");
    return 1;
  }

  printf("enc %d:",strlen((char*)DstData)); 
  
  for(i = 0;DstData[i];i++)
    printf("%x",(unsigned char)DstData[i]);

  printf("\n");
  return 0;
}
